package com.cndongtai.dao.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import com.cndongtai.dao.BaseDao;
import com.cndongtai.dao.inter.RoleMenuMapper;
import com.cndongtai.po.RoleMenu;

@Repository("roleMenuDao")
public class RoleMenuDao extends BaseDao implements RoleMenuMapper {

	@Override
	public boolean addRoleMenu(RoleMenu roleMenu) {
		SqlSession sqlSession = getSqlSession();
		try {
			RoleMenuMapper operation = sqlSession.getMapper(RoleMenuMapper.class);
			return operation.addRoleMenu(roleMenu);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return false;
	}

	@Override
	public List<RoleMenu> queryRoleMenuByRoleId(Long roleId) {
		SqlSession sqlSession = getSqlSession();
		try {
			RoleMenuMapper operation = sqlSession.getMapper(RoleMenuMapper.class);
			return operation.queryRoleMenuByRoleId(roleId);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return null;
	}

	@Override
	public boolean delRoleMenuByRoleId(Long roleId) {
		SqlSession sqlSession = getSqlSession();
		try {
			RoleMenuMapper operation = sqlSession.getMapper(RoleMenuMapper.class);
			return operation.delRoleMenuByRoleId(roleId);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return false;
	}

}
